package homework.chapter12;

import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;

public class EmployeeAgeComparator implements Comparator<Employee> {
    private Collator collator = Collator.getInstance(Locale.CHINA);

    @Override
    public int compare(Employee e1, Employee e2) {
        if (e1.getAge() != e2.getAge()) {
            return Integer.compare(e1.getAge(), e2.getAge());
        } else {
            return collator.compare(e1.getName(), e2.getName());
        }
    }
}
